﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using AutoFacUtils;
using CashFlow.Db.Entity;
using CashFlow.Web.Filters;
using CashFlow.Web.Common;
using CashFlow.Web.Areas.ShopManage.Models.User;
using CashFlow.Web.Areas.ShopManage.Validator.User;
using CashFlow.Web.Service;

namespace CashFlow.Web.Areas.ShopManage.Controllers
{
    [ShopManagerFilter]
    public class UserAccountController : Controller
    {
        private IUserAccountInfoService GetUserAccountInfoService() { return AutoFacHelper.Get<IUserAccountInfoService>(); }

        [HttpPost]
        [ValidatorFilter(typeof(QueryUserAccountModelValidator))]
        public ActionResult QueryByUserId(QueryUserAccountModel model)
        {
            var service = GetUserAccountInfoService();
            var entity = service.QuerySingle(x => x.UserId == model.UserId);
            var entity2 = entity ?? new UserAccountInfoEntity();
            return MyCommonTool.CreateOperationResult(true, "", entity2);
        }
    }
}